<?php
namespace app\admin\controller;
use think\Controller;
use app\index\model\User;
class Auth extends Controller
{
	protected $is_login = [''];
	public function _initialize()
	{
		if (!$this->checklogin() && $this->is_login[0] == '*') {
			$this->error('您还没有登录，请先登录333',url('admin/admin/index'));
		}
	}
	public function checklogin()
	{
		return session('?admin');//真|jia 
	}
	public function login()
	{
		return $this->fetch();
	}
	public function dologin()
	{
		$info = User::where(['user_name'=>input('text')])->find();
		if ($info) {
			session('haha',$info->toArray());
			$this->success('成功',url('admin/admin/index'));
		} else {
			$this->error('您还没有登录，请先登录',url('admin/admin/index'));
		}
	}
	public function loginout()
	{
		session(null);
		$this->error('您还没有登录，请先登录',url('admin/auth/login'));
	}
}